import pandas as pd
import numpy as np

my_list=['算法','数据挖掘','图像']
my_list1=['1班','2班','3班']
for l in my_list:
    for i in my_list1:
        # print("正在分离含有\"{}\"的".format(l) +format(i) +"数据")
        input_file = "./data4_1_classify_name/{}".format(l) + ".xlsx"
        output_file = "./data4_2_classify_name/{}_{}.xlsx".format(l, i)
        # output_file="./data4_1_classify_name/{}".format(l)+format(i) +"xlsx"
        data1 = pd.read_excel(input_file)

        data1 = data1.drop("Unnamed: 0",axis=1)
        data1 = data1.values
        name = []
        class1 = []
        sex = []
        math = []
        Chinese = []
        for item in data1:
            print(item)
            if i in item[1]:
                print(i)
                name.append(item[0])
                class1.append(item[1])
                sex.append(item[2])
                math.append(item[3])
                Chinese.append(item[4])
        data2 = {"name": name,
                 "class1": class1,
                 "sex": sex,
                 "math": math,
                 "Chinese": Chinese}
        print(data2)
        data2 = pd.DataFrame(data2)
        data2.to_excel(output_file)
        print(data2)


